Merged
Conversation
This commit applies several cleanups to the `src/loop.rs` file to improve code clarity, robustness, and adherence to Rust idioms. - Removed unnecessary `#[inline]` attributes from internal helper functions. The compiler's own heuristics are sufficient for making inlining decisions for these private, non-generic functions, making the explicit attribute redundant. - Replaced `.unwrap()` with `anyhow::Context` when opening the backing file. This provides more informative error messages if the file cannot be opened, improving diagnostics. - Simplified the logic in `ublk_add_loop` for handling device recovery and command-line options, making the code easier to follow and maintain. Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Enable discard support for the null target unconditionally. The null device now advertises discard capabilities and handles discard/write-zeroes commands by returning a success status (0), as no actual data operation is needed. Also, add a basic integration test to verify that the `blkdiscard` command runs successfully against a `rublk` null device. Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Create a single `has_blkdiscard()` helper function to check for the availability of the `blkdiscard` command. This refactoring removes code duplication from the `test_ublk_loop_discard` and `test_ublk_null_discard` tests, making the test suite cleaner and easier to maintain. Signed-off-by: Ming Lei <tom.leiming@gmail.com>
This commit refactors `src/args.rs` to improve code clarity, robustness, and adherence to Rust idioms. - Replaced `.unwrap()` calls with `?` to ensure proper error propagation when building the `UblkCtrl` object. - Simplified boolean flag handling for setting control flags. - Added comments to clarify the purpose of the `start_dir` field and the `round_up` and `is_power2_of` helper functions. - Improved the implementation of `is_power2_of` to use the standard library's `is_power_of_two()` for better readability. Signed-off-by: Ming Lei <tom.leiming@gmail.com>
When `rublk add` is run in a subshell, as in `$(rublk add null)`, the parent shell waits for the daemon's stdout and stderr file descriptors to close. Previously, these were kept open, causing the parent to hang indefinitely. This commit fixes the issue by redirecting the daemon's stdout and stderr to `/dev/null`. This allows the daemon to fully detach, preventing the parent shell from hanging and enabling correct behavior in subshells. Signed-off-by: Ming Lei <tom.leiming@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
630fd3e fix: Fully detach daemon process
3ce39c7 refactor(args): Clean up command-line argument parsing
6d3cb3d refactor(tests): Abstract has_blkdiscard() helper
0b9424b feat(null): Add unconditional discard support
5acacca refactor(loop): Clean up and simplify loop target implementation